<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>perlunifaq - Perl Unicode FAQ - Perldoc Browser</title>
    <link rel="search" href="https://perldoc.perl.org/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser">
    <link rel="canonical" href="https://perldoc.perl.org/perlunifaq">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" />
    <style>
      body {
        background: #f4f4f5;
        color: #020202;
      }
      .navbar-dark {
        background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0);
        background-repeat: repeat-x;
      }
      .navbar-dark .navbar-nav .nav-link,
      .navbar-dark .navbar-nav .nav-link:focus { color: #fff }
      .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 }
      #wrapperlicious {
        margin: 0 auto;
        font: 0.9em 'Helvetica Neue', Helvetica, sans-serif;
        font-weight: normal;
        line-height: 1.5em;
        margin: 0;
        padding: 0;
      }
      #wrapperlicious h1 { font-size: 1.5em }
      #wrapperlicious h2 { font-size: 1.3em }
      #wrapperlicious h3 { font-size: 1.1em }
      #wrapperlicious h4 { font-size: 0.9em }
      #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3,
      #wrapperlicious h4, #wrapperlicious dt {
        color: #020202;
        margin-top: 1em;
        margin-bottom: 1em;
        position: relative;
        font-weight: bold;
      }
      #wrapperlicious a { color: inherit; text-decoration: underline }
      #wrapperlicious #toc { text-decoration: none }
      #wrapperlicious a:hover { color: #2a2a2a }
      #wrapperlicious a img { border: 0 }
      #wrapperlicious :not(pre) > code {
        color: inherit;
        background-color: rgba(0, 0, 0, 0.04);
        border-radius: 3px;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        padding: 0.3em;
      }
      #wrapperlicious dd {
        margin: 0;
        margin-left: 2em;
      }
      #wrapperlicious dt {
        color: #2a2a2a;
        font-weight: bold;
        margin-left: 0.9em;
      }
      #wrapperlicious p {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious li > p {
        margin-bottom: 0;
        margin-top: 0;
      }
      #wrapperlicious pre {
        border: 1px solid #c1c1c1;
        border-radius: 3px;
        font: 100% Consolas, Menlo, Monaco, monospace;
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious pre > code {
        display: block;
        background-color: #f6f6f6;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        line-height: 1.5em;
        text-align: left;
        white-space: pre;
        padding: 1em;
      }
      #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious ul {
        list-style-type: square;
      }
      #wrapperlicious ul ul {
        margin-bottom: 0px;
        margin-top: 0px;
      }
      #footer {
        font-size: 0.8em;
        padding-top: 0.5em;
        text-align: center;
      }
      #more {
        display: inline;
        font-size: 0.8em;
      }
      #perldocdiv {
        background-color: #fff;
        border: 1px solid #c1c1c1;
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
        margin-left: auto;
        margin-right: auto;
        padding: 3em;
        padding-top: 1em;
        max-width: 960px;
      }
      #moduleversion { float: right }
      #wrapperlicious .leading-notice {
        font-style: italic;
        padding-left: 1em;
        margin-top: 1em;
        margin-bottom: 1em;
      }
      #wrapperlicious .permalink {
        display: none;
        left: -0.75em;
        position: absolute;
        padding-right: 0.25em;
        text-decoration: none;
      }
      #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink,
      #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink,
      #wrapperlicious dt:hover .permalink {
        display: block;
      }
    </style>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-KVNWBNT5FB');
      gtag('config', 'UA-50555-3');
    </script>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between">
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="https://perldoc.perl.org/">Perldoc Browser</a>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perlunifaq.html#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.35.0</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-stable">
          <a class="dropdown-item" href="https://perldoc.perl.org/perlunifaq">Latest</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.2/perlunifaq">5.38.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.1/perlunifaq">5.38.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0/perlunifaq">5.38.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.3/perlunifaq">5.36.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.2/perlunifaq">5.36.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.1/perlunifaq">5.36.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.0/perlunifaq">5.36.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.3/perlunifaq">5.34.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.2/perlunifaq">5.34.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.1/perlunifaq">5.34.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.0/perlunifaq">5.34.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.1/perlunifaq">5.32.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.0/perlunifaq">5.32.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.3/perlunifaq">5.30.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.2/perlunifaq">5.30.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.1/perlunifaq">5.30.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.0/perlunifaq">5.30.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.3/perlunifaq">5.28.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.2/perlunifaq">5.28.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.1/perlunifaq">5.28.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.0/perlunifaq">5.28.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.3/perlunifaq">5.26.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.2/perlunifaq">5.26.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.1/perlunifaq">5.26.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.0/perlunifaq">5.26.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.4/perlunifaq">5.24.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.3/perlunifaq">5.24.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.2/perlunifaq">5.24.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.1/perlunifaq">5.24.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.0/perlunifaq">5.24.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.4/perlunifaq">5.22.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.3/perlunifaq">5.22.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.2/perlunifaq">5.22.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.1/perlunifaq">5.22.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.0/perlunifaq">5.22.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.3/perlunifaq">5.20.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.2/perlunifaq">5.20.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.1/perlunifaq">5.20.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.0/perlunifaq">5.20.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.4/perlunifaq">5.18.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.3/perlunifaq">5.18.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.2/perlunifaq">5.18.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.1/perlunifaq">5.18.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.0/perlunifaq">5.18.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.3/perlunifaq">5.16.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.2/perlunifaq">5.16.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.1/perlunifaq">5.16.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.0/perlunifaq">5.16.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.4/perlunifaq">5.14.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.3/perlunifaq">5.14.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.2/perlunifaq">5.14.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.1/perlunifaq">5.14.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.0/perlunifaq">5.14.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.5/perlunifaq">5.12.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.4/perlunifaq">5.12.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.3/perlunifaq">5.12.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.2/perlunifaq">5.12.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.1/perlunifaq">5.12.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.0/perlunifaq">5.12.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.1/perlunifaq">5.10.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.0/perlunifaq">5.10.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.9/perlunifaq">5.8.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.8/perlunifaq">5.8.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.7/perlunifaq">5.8.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.6/perlunifaq">5.8.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.5/perlunifaq">5.8.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.4/perlunifaq">5.8.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.3/perlunifaq">5.8.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.2/perlunifaq">5.8.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.1/perlunifaq">5.8.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.0/perlunifaq">5.8.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.2/perlunifaq">5.6.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.1/perlunifaq">5.6.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.0/perlunifaq">5.6.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_04/perlunifaq">5.005_04</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_03/perlunifaq">5.005_03</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_02/perlunifaq">5.005_02</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_01/perlunifaq">5.005_01</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005/perlunifaq">5.005</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perlunifaq.html#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-dev">
          <a class="dropdown-item" href="https://perldoc.perl.org/blead/perlunifaq">blead</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.6/perlunifaq">5.39.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.5/perlunifaq">5.39.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.4/perlunifaq">5.39.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.3/perlunifaq">5.39.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.2/perlunifaq">5.39.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.1/perlunifaq">5.39.1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC2/perlunifaq">5.38.0-RC2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC1/perlunifaq">5.38.0-RC1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.11/perlunifaq">5.37.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.10/perlunifaq">5.37.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.9/perlunifaq">5.37.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.8/perlunifaq">5.37.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.7/perlunifaq">5.37.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.6/perlunifaq">5.37.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.5/perlunifaq">5.37.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.4/perlunifaq">5.37.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.3/perlunifaq">5.37.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.2/perlunifaq">5.37.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.1/perlunifaq">5.37.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.0/perlunifaq">5.37.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.11/perlunifaq">5.35.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.10/perlunifaq">5.35.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.9/perlunifaq">5.35.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.8/perlunifaq">5.35.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.7/perlunifaq">5.35.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.6/perlunifaq">5.35.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.5/perlunifaq">5.35.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.4/perlunifaq">5.35.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.3/perlunifaq">5.35.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.2/perlunifaq">5.35.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.1/perlunifaq">5.35.1</a>
          <a class="dropdown-item active" href="perlunifaq.html">5.35.0</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="perlunifaq.html#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-nav">
          <a class="dropdown-item" href="perl.html">Perl</a>
          <a class="dropdown-item" href="perlintro.html">Intro</a>
          <a class="dropdown-item" href="perl.html#Tutorials">Tutorials</a>
          <a class="dropdown-item" href="perlfaq.html">FAQs</a>
          <a class="dropdown-item" href="perl.html#Reference-Manual">Reference</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlop.html">Operators</a>
          <a class="dropdown-item" href="functions.html">Functions</a>
          <a class="dropdown-item" href="variables.html">Variables</a>
          <a class="dropdown-item" href="modules.html">Modules</a>
          <a class="dropdown-item" href="perlutil.html">Utilities</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlcommunity.html">Community</a>
          <a class="dropdown-item" href="perlhist.html">History</a>
        </div>
      </li>
    </ul>
    <ul class="navbar-nav">
      <script>
        function set_expand (expand) {
          var perldocdiv = document.getElementById('perldocdiv');
          var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width');
          var expanded = (width == '' || width == 'none') ? true : false;
          if (expand === null) {
            expand = !expanded;
          }
          if ((expand && !expanded) || (!expand && expanded)) {
            perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px');
            var button_classlist = document.getElementById('content-expand-button').classList;
            if (expand) {
              button_classlist.add('btn-light');
              button_classlist.remove('btn-outline-light');
            } else {
              button_classlist.add('btn-outline-light');
              button_classlist.remove('btn-light');
            }
          }
          return expand;
        }
        function toggle_expand () {
          var expand = set_expand(null);
          document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC';
        }
        function read_expand () {
          return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 });
        }
        if (document.readyState === 'loading') {
          document.addEventListener('DOMContentLoaded', function () {
            if (read_expand()) {
              set_expand(true);
            }
          });
        } else if (read_expand()) {
          set_expand(true);
        }
      </script>
      <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-2" onclick="toggle_expand()">Expand</button>
    <ul>
    <form class="form-inline" method="get" action="https://perldoc.perl.org/5.35.0/search">
      <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search">
    </form>
  </div>
</nav>

    <div id="wrapperlicious" class="container-fluid">
      <div id="perldocdiv">
        <div id="links">
          <a href="perlunifaq.html">perlunifaq</a>
          <div id="more">
            (<a href="perlunifaq.txt">source</a>,
            <a href="https://metacpan.org/pod/perlunifaq">CPAN</a>)
          </div>
        </div>
        <div class="leading-notice">
          You are viewing the version of this documentation from Perl 5.35.0.
            This is a development version of Perl.
        </div>
        <h1><a id="toc">CONTENTS</a></h1>
                  <ul>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#NAME">NAME</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#Q-and-A">Q and A</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#perlunitut-isn&#39;t-really-a-Unicode-tutorial,-is-it?">perlunitut isn&#39;t really a Unicode tutorial, is it?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#What-character-encodings-does-Perl-support?">What character encodings does Perl support?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#Which-version-of-perl-should-I-use?">Which version of perl should I use?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#What-about-binary-data,-like-images?">What about binary data, like images?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#When-should-I-decode-or-encode?">When should I decode or encode?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#What-if-I-don&#39;t-decode?">What if I don&#39;t decode?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#What-if-I-don&#39;t-encode?">What if I don&#39;t encode?</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#Output-via-a-filehandle">Output via a filehandle</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#Other-output-mechanisms-(e.g.,-exec,-chdir,-..)">Other output mechanisms (e.g., exec, chdir, ..)</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#Is-there-a-way-to-automatically-decode-or-encode?">Is there a way to automatically decode or encode?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#What-if-I-don&#39;t-know-which-encoding-was-used?">What if I don&#39;t know which encoding was used?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#Can-I-use-Unicode-in-my-Perl-sources?">Can I use Unicode in my Perl sources?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#Data::Dumper-doesn&#39;t-restore-the-UTF8-flag;-is-it-broken?">Data::Dumper doesn&#39;t restore the UTF8 flag; is it broken?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#Why-do-regex-character-classes-sometimes-match-only-in-the-ASCII-range?">Why do regex character classes sometimes match only in the ASCII range?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#Why-do-some-characters-not-uppercase-or-lowercase-correctly?">Why do some characters not uppercase or lowercase correctly?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#How-can-I-determine-if-a-string-is-a-text-string-or-a-binary-string?">How can I determine if a string is a text string or a binary string?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#How-do-I-convert-from-encoding-FOO-to-encoding-BAR?">How do I convert from encoding FOO to encoding BAR?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#What-are-decode_utf8-and-encode_utf8?">What are decode_utf8 and encode_utf8?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#What-is-a-%22wide-character%22?">What is a &quot;wide character&quot;?</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#INTERNALS">INTERNALS</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#What-is-%22the-UTF8-flag%22?">What is &quot;the UTF8 flag&quot;?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#What-about-the-use-bytes-pragma?">What about the use bytes pragma?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#What-about-the-use-encoding-pragma?">What about the use encoding pragma?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#What-is-the-difference-between-:encoding-and-:utf8?">What is the difference between :encoding and :utf8?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#What&#39;s-the-difference-between-UTF-8-and-utf8?">What&#39;s the difference between UTF-8 and utf8?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#I-lost-track;-what-encoding-is-the-internal-format-really?">I lost track; what encoding is the internal format really?</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#AUTHOR">AUTHOR</a>
              </li>
              <li>
                <a class="text-decoration-none" href="perlunifaq.html#SEE-ALSO">SEE ALSO</a>
              </li>
          </ul>

      <h1 id="NAME"><a class="permalink" href="perlunifaq.html#NAME">#</a>NAME</h1>

<p>perlunifaq - Perl Unicode FAQ</p>

<h1 id="Q-and-A"><a class="permalink" href="perlunifaq.html#Q-and-A">#</a><a id="Q"></a>Q and A</h1>

<p>This is a list of questions and answers about Unicode in Perl, intended to be read after <a href="perlunitut.html">perlunitut</a>.</p>

<h2 id="perlunitut-isn&#39;t-really-a-Unicode-tutorial,-is-it?"><a class="permalink" href="perlunifaq.html#perlunitut-isn&#39;t-really-a-Unicode-tutorial,-is-it?">#</a><a id="perlunitut"></a><a id="perlunitut-isnt-really-a-Unicode-tutorial-is-it"></a>perlunitut isn&#39;t really a Unicode tutorial, is it?</h2>

<p>No, and this isn&#39;t really a Unicode FAQ.</p>

<p>Perl has an abstracted interface for all supported character encodings, so this is actually a generic <code>Encode</code> tutorial and <code>Encode</code> FAQ. But many people think that Unicode is special and magical, and I didn&#39;t want to disappoint them, so I decided to call the document a Unicode tutorial.</p>

<h2 id="What-character-encodings-does-Perl-support?"><a class="permalink" href="perlunifaq.html#What-character-encodings-does-Perl-support?">#</a><a id="What"></a><a id="What-character-encodings-does-Perl-support"></a>What character encodings does Perl support?</h2>

<p>To find out which character encodings your Perl supports, run:</p>

<pre><code>perl -MEncode -le &quot;print for Encode-&gt;encodings(&#39;:all&#39;)&quot;</code></pre>

<h2 id="Which-version-of-perl-should-I-use?"><a class="permalink" href="perlunifaq.html#Which-version-of-perl-should-I-use?">#</a><a id="Which"></a><a id="Which-version-of-perl-should-I-use"></a>Which version of perl should I use?</h2>

<p>Well, if you can, upgrade to the most recent, but certainly <code>5.8.1</code> or newer. The tutorial and FAQ assume the latest release.</p>

<p>You should also check your modules, and upgrade them if necessary. For example, HTML::Entities requires version &gt;= 1.32 to function correctly, even though the changelog is silent about this.</p>

<h2 id="What-about-binary-data,-like-images?"><a class="permalink" href="perlunifaq.html#What-about-binary-data,-like-images?">#</a><a id="What1"></a><a id="What-about-binary-data-like-images"></a>What about binary data, like images?</h2>

<p>Well, apart from a bare <code>binmode $fh</code>, you shouldn&#39;t treat them specially. (The binmode is needed because otherwise Perl may convert line endings on Win32 systems.)</p>

<p>Be careful, though, to never combine text strings with binary strings. If you need text in a binary stream, encode your text strings first using the appropriate encoding, then join them with binary strings. See also: &quot;What if I don&#39;t encode?&quot;.</p>

<h2 id="When-should-I-decode-or-encode?"><a class="permalink" href="perlunifaq.html#When-should-I-decode-or-encode?">#</a><a id="When"></a><a id="When-should-I-decode-or-encode"></a>When should I decode or encode?</h2>

<p>Whenever you&#39;re communicating text with anything that is external to your perl process, like a database, a text file, a socket, or another program. Even if the thing you&#39;re communicating with is also written in Perl.</p>

<h2 id="What-if-I-don&#39;t-decode?"><a class="permalink" href="perlunifaq.html#What-if-I-don&#39;t-decode?">#</a><a id="What2"></a><a id="What-if-I-dont-decode"></a>What if I don&#39;t decode?</h2>

<p>Whenever your encoded, binary string is used together with a text string, Perl will assume that your binary string was encoded with ISO-8859-1, also known as latin-1. If it wasn&#39;t latin-1, then your data is unpleasantly converted. For example, if it was UTF-8, the individual bytes of multibyte characters are seen as separate characters, and then again converted to UTF-8. Such double encoding can be compared to double HTML encoding (<code>&amp;amp;gt;</code>), or double URI encoding (<code>%253E</code>).</p>

<p>This silent implicit decoding is known as &quot;upgrading&quot;. That may sound positive, but it&#39;s best to avoid it.</p>

<h2 id="What-if-I-don&#39;t-encode?"><a class="permalink" href="perlunifaq.html#What-if-I-don&#39;t-encode?">#</a><a id="What3"></a><a id="What-if-I-dont-encode"></a>What if I don&#39;t encode?</h2>

<p>It depends on what you output and how you output it.</p>

<h3 id="Output-via-a-filehandle"><a class="permalink" href="perlunifaq.html#Output-via-a-filehandle">#</a><a id="Output"></a>Output via a filehandle</h3>

<ul>

<li><p>If the string&#39;s characters are all code point 255 or lower, Perl outputs bytes that match those code points. This is what happens with encoded strings. It can also, though, happen with unencoded strings that happen to be all code point 255 or lower.</p>

</li>
<li><p>Otherwise, Perl outputs the string encoded as UTF-8. This only happens with strings you neglected to encode. Since that should not happen, Perl also throws a &quot;wide character&quot; warning in this case.</p>

</li>
</ul>

<h3 id="Other-output-mechanisms-(e.g.,-exec,-chdir,-..)"><a class="permalink" href="perlunifaq.html#Other-output-mechanisms-(e.g.,-exec,-chdir,-..)">#</a><a id="Other"></a><a id="Other-output-mechanisms-e.g.-exec-chdir"></a>Other output mechanisms (e.g., <code>exec</code>, <code>chdir</code>, ..)</h3>

<p>Your text string will be sent using the bytes in Perl&#39;s internal format.</p>

<p>Because the internal format is often UTF-8, these bugs are hard to spot, because UTF-8 is usually the encoding you wanted! But don&#39;t be lazy, and don&#39;t use the fact that Perl&#39;s internal format is UTF-8 to your advantage. Encode explicitly to avoid weird bugs, and to show to maintenance programmers that you thought this through.</p>

<h2 id="Is-there-a-way-to-automatically-decode-or-encode?"><a class="permalink" href="perlunifaq.html#Is-there-a-way-to-automatically-decode-or-encode?">#</a><a id="Is"></a><a id="Is-there-a-way-to-automatically-decode-or-encode"></a>Is there a way to automatically decode or encode?</h2>

<p>If all data that comes from a certain handle is encoded in exactly the same way, you can tell the PerlIO system to automatically decode everything, with the <code>encoding</code> layer. If you do this, you can&#39;t accidentally forget to decode or encode anymore, on things that use the layered handle.</p>

<p>You can provide this layer when <code>open</code>ing the file:</p>

<pre><code>open my $fh, &#39;&gt;:encoding(UTF-8)&#39;, $filename;  # auto encoding on write
open my $fh, &#39;&lt;:encoding(UTF-8)&#39;, $filename;  # auto decoding on read</code></pre>

<p>Or if you already have an open filehandle:</p>

<pre><code>binmode $fh, &#39;:encoding(UTF-8)&#39;;</code></pre>

<p>Some database drivers for DBI can also automatically encode and decode, but that is sometimes limited to the UTF-8 encoding.</p>

<h2 id="What-if-I-don&#39;t-know-which-encoding-was-used?"><a class="permalink" href="perlunifaq.html#What-if-I-don&#39;t-know-which-encoding-was-used?">#</a><a id="What4"></a><a id="What-if-I-dont-know-which-encoding-was-used"></a>What if I don&#39;t know which encoding was used?</h2>

<p>Do whatever you can to find out, and if you have to: guess. (Don&#39;t forget to document your guess with a comment.)</p>

<p>You could open the document in a web browser, and change the character set or character encoding until you can visually confirm that all characters look the way they should.</p>

<p>There is no way to reliably detect the encoding automatically, so if people keep sending you data without charset indication, you may have to educate them.</p>

<h2 id="Can-I-use-Unicode-in-my-Perl-sources?"><a class="permalink" href="perlunifaq.html#Can-I-use-Unicode-in-my-Perl-sources?">#</a><a id="Can"></a><a id="Can-I-use-Unicode-in-my-Perl-sources"></a>Can I use Unicode in my Perl sources?</h2>

<p>Yes, you can! If your sources are UTF-8 encoded, you can indicate that with the <code>use utf8</code> pragma.</p>

<pre><code>use utf8;</code></pre>

<p>This doesn&#39;t do anything to your input, or to your output. It only influences the way your sources are read. You can use Unicode in string literals, in identifiers (but they still have to be &quot;word characters&quot; according to <code>\w</code>), and even in custom delimiters.</p>

<h2 id="Data::Dumper-doesn&#39;t-restore-the-UTF8-flag;-is-it-broken?"><a class="permalink" href="perlunifaq.html#Data::Dumper-doesn&#39;t-restore-the-UTF8-flag;-is-it-broken?">#</a><a id="Data"></a><a id="Data::Dumper-doesnt-restore-the-UTF8-flag-is-it-broken"></a>Data::Dumper doesn&#39;t restore the UTF8 flag; is it broken?</h2>

<p>No, Data::Dumper&#39;s Unicode abilities are as they should be. There have been some complaints that it should restore the UTF8 flag when the data is read again with <code>eval</code>. However, you should really not look at the flag, and nothing indicates that Data::Dumper should break this rule.</p>

<p>Here&#39;s what happens: when Perl reads in a string literal, it sticks to 8 bit encoding as long as it can. (But perhaps originally it was internally encoded as UTF-8, when you dumped it.) When it has to give that up because other characters are added to the text string, it silently upgrades the string to UTF-8.</p>

<p>If you properly encode your strings for output, none of this is of your concern, and you can just <code>eval</code> dumped data as always.</p>

<h2 id="Why-do-regex-character-classes-sometimes-match-only-in-the-ASCII-range?"><a class="permalink" href="perlunifaq.html#Why-do-regex-character-classes-sometimes-match-only-in-the-ASCII-range?">#</a><a id="Why"></a><a id="Why-do-regex-character-classes-sometimes-match-only-in-the-ASCII-range"></a>Why do regex character classes sometimes match only in the ASCII range?</h2>

<p>Starting in Perl 5.14 (and partially in Perl 5.12), just put a <code>use feature &#39;unicode_strings&#39;</code> near the beginning of your program. Within its lexical scope you shouldn&#39;t have this problem. It also is automatically enabled under <code>use feature &#39;:5.12&#39;</code> or <code>use v5.12</code> or using <code>-E</code> on the command line for Perl 5.12 or higher.</p>

<p>The rationale for requiring this is to not break older programs that rely on the way things worked before Unicode came along. Those older programs knew only about the ASCII character set, and so may not work properly for additional characters. When a string is encoded in UTF-8, Perl assumes that the program is prepared to deal with Unicode, but when the string isn&#39;t, Perl assumes that only ASCII is wanted, and so those characters that are not ASCII characters aren&#39;t recognized as to what they would be in Unicode. <code>use feature &#39;unicode_strings&#39;</code> tells Perl to treat all characters as Unicode, whether the string is encoded in UTF-8 or not, thus avoiding the problem.</p>

<p>However, on earlier Perls, or if you pass strings to subroutines outside the feature&#39;s scope, you can force Unicode rules by changing the encoding to UTF-8 by doing <code>utf8::upgrade($string)</code>. This can be used safely on any string, as it checks and does not change strings that have already been upgraded.</p>

<p>For a more detailed discussion, see <a href="./Unicode::Semantics.html">Unicode::Semantics</a> on CPAN.</p>

<h2 id="Why-do-some-characters-not-uppercase-or-lowercase-correctly?"><a class="permalink" href="perlunifaq.html#Why-do-some-characters-not-uppercase-or-lowercase-correctly?">#</a><a id="Why1"></a><a id="Why-do-some-characters-not-uppercase-or-lowercase-correctly"></a>Why do some characters not uppercase or lowercase correctly?</h2>

<p>See the answer to the previous question.</p>

<h2 id="How-can-I-determine-if-a-string-is-a-text-string-or-a-binary-string?"><a class="permalink" href="perlunifaq.html#How-can-I-determine-if-a-string-is-a-text-string-or-a-binary-string?">#</a><a id="How"></a><a id="How-can-I-determine-if-a-string-is-a-text-string-or-a-binary-string"></a>How can I determine if a string is a text string or a binary string?</h2>

<p>You can&#39;t. Some use the UTF8 flag for this, but that&#39;s misuse, and makes well behaved modules like Data::Dumper look bad. The flag is useless for this purpose, because it&#39;s off when an 8 bit encoding (by default ISO-8859-1) is used to store the string.</p>

<p>This is something you, the programmer, has to keep track of; sorry. You could consider adopting a kind of &quot;Hungarian notation&quot; to help with this.</p>

<h2 id="How-do-I-convert-from-encoding-FOO-to-encoding-BAR?"><a class="permalink" href="perlunifaq.html#How-do-I-convert-from-encoding-FOO-to-encoding-BAR?">#</a><a id="How1"></a><a id="How-do-I-convert-from-encoding-FOO-to-encoding-BAR"></a>How do I convert from encoding FOO to encoding BAR?</h2>

<p>By first converting the FOO-encoded byte string to a text string, and then the text string to a BAR-encoded byte string:</p>

<pre><code>my $text_string = decode(&#39;FOO&#39;, $foo_string);
my $bar_string  = encode(&#39;BAR&#39;, $text_string);</code></pre>

<p>or by skipping the text string part, and going directly from one binary encoding to the other:</p>

<pre><code>use Encode qw(from_to);
from_to($string, &#39;FOO&#39;, &#39;BAR&#39;);  # changes contents of $string</code></pre>

<p>or by letting automatic decoding and encoding do all the work:</p>

<pre><code>open my $foofh, &#39;&lt;:encoding(FOO)&#39;, &#39;example.foo.txt&#39;;
open my $barfh, &#39;&gt;:encoding(BAR)&#39;, &#39;example.bar.txt&#39;;
print { $barfh } $_ while &lt;$foofh&gt;;</code></pre>

<h2 id="What-are-decode_utf8-and-encode_utf8?"><a class="permalink" href="perlunifaq.html#What-are-decode_utf8-and-encode_utf8?">#</a><a id="What5"></a><a id="What-are-decode_utf8-and-encode_utf8"></a>What are <code>decode_utf8</code> and <code>encode_utf8</code>?</h2>

<p>These are alternate syntaxes for <code>decode(&#39;utf8&#39;, ...)</code> and <code>encode(&#39;utf8&#39;, ...)</code>. Do not use these functions for data exchange. Instead use <code>decode(&#39;UTF-8&#39;, ...)</code> and <code>encode(&#39;UTF-8&#39;, ...)</code>; see <a href="perlunifaq.html#What%27s-the-difference-between-UTF-8-and-utf8%3F">&quot;What&#39;s the difference between UTF-8 and utf8?&quot;</a> below.</p>

<h2 id="What-is-a-&quot;wide-character&quot;?"><a class="permalink" href="perlunifaq.html#What-is-a-%22wide-character%22?">#</a><a id="What6"></a><a id="What-is-a-wide-character"></a>What is a &quot;wide character&quot;?</h2>

<p>This is a term used for characters occupying more than one byte.</p>

<p>The Perl warning &quot;Wide character in ...&quot; is caused by such a character. With no specified encoding layer, Perl tries to fit things into a single byte. When it can&#39;t, it emits this warning (if warnings are enabled), and uses UTF-8 encoded data instead.</p>

<p>To avoid this warning and to avoid having different output encodings in a single stream, always specify an encoding explicitly, for example with a PerlIO layer:</p>

<pre><code>binmode STDOUT, &quot;:encoding(UTF-8)&quot;;</code></pre>

<h1 id="INTERNALS"><a class="permalink" href="perlunifaq.html#INTERNALS">#</a>INTERNALS</h1>

<h2 id="What-is-&quot;the-UTF8-flag&quot;?"><a class="permalink" href="perlunifaq.html#What-is-%22the-UTF8-flag%22?">#</a><a id="What7"></a><a id="What-is-the-UTF8-flag"></a>What is &quot;the UTF8 flag&quot;?</h2>

<p>Please, unless you&#39;re hacking the internals, or debugging weirdness, don&#39;t think about the UTF8 flag at all. That means that you very probably shouldn&#39;t use <code>is_utf8</code>, <code>_utf8_on</code> or <code>_utf8_off</code> at all.</p>

<p>The UTF8 flag, also called SvUTF8, is an internal flag that indicates that the current internal representation is UTF-8. Without the flag, it is assumed to be ISO-8859-1. Perl converts between these automatically. (Actually Perl usually assumes the representation is ASCII; see <a href="perlunifaq.html#Why-do-regex-character-classes-sometimes-match-only-in-the-ASCII-range%3F">&quot;Why do regex character classes sometimes match only in the ASCII range?&quot;</a> above.)</p>

<p>One of Perl&#39;s internal formats happens to be UTF-8. Unfortunately, Perl can&#39;t keep a secret, so everyone knows about this. That is the source of much confusion. It&#39;s better to pretend that the internal format is some unknown encoding, and that you always have to encode and decode explicitly.</p>

<h2 id="What-about-the-use-bytes-pragma?"><a class="permalink" href="perlunifaq.html#What-about-the-use-bytes-pragma?">#</a><a id="What8"></a><a id="What-about-the-use-bytes-pragma"></a>What about the <code>use bytes</code> pragma?</h2>

<p>Don&#39;t use it. It makes no sense to deal with bytes in a text string, and it makes no sense to deal with characters in a byte string. Do the proper conversions (by decoding/encoding), and things will work out well: you get character counts for decoded data, and byte counts for encoded data.</p>

<p><code>use bytes</code> is usually a failed attempt to do something useful. Just forget about it.</p>

<h2 id="What-about-the-use-encoding-pragma?"><a class="permalink" href="perlunifaq.html#What-about-the-use-encoding-pragma?">#</a><a id="What9"></a><a id="What-about-the-use-encoding-pragma"></a>What about the <code>use encoding</code> pragma?</h2>

<p>Don&#39;t use it. Unfortunately, it assumes that the programmer&#39;s environment and that of the user will use the same encoding. It will use the same encoding for the source code and for STDIN and STDOUT. When a program is copied to another machine, the source code does not change, but the STDIO environment might.</p>

<p>If you need non-ASCII characters in your source code, make it a UTF-8 encoded file and <code>use utf8</code>.</p>

<p>If you need to set the encoding for STDIN, STDOUT, and STDERR, for example based on the user&#39;s locale, <code>use open</code>.</p>

<h2 id="What-is-the-difference-between-:encoding-and-:utf8?"><a class="permalink" href="perlunifaq.html#What-is-the-difference-between-:encoding-and-:utf8?">#</a><a id="What10"></a><a id="What-is-the-difference-between-:encoding-and-:utf8"></a>What is the difference between <code>:encoding</code> and <code>:utf8</code>?</h2>

<p>Because UTF-8 is one of Perl&#39;s internal formats, you can often just skip the encoding or decoding step, and manipulate the UTF8 flag directly.</p>

<p>Instead of <code>:encoding(UTF-8)</code>, you can simply use <code>:utf8</code>, which skips the encoding step if the data was already represented as UTF8 internally. This is widely accepted as good behavior when you&#39;re writing, but it can be dangerous when reading, because it causes internal inconsistency when you have invalid byte sequences. Using <code>:utf8</code> for input can sometimes result in security breaches, so please use <code>:encoding(UTF-8)</code> instead.</p>

<p>Instead of <code>decode</code> and <code>encode</code>, you could use <code>_utf8_on</code> and <code>_utf8_off</code>, but this is considered bad style. Especially <code>_utf8_on</code> can be dangerous, for the same reason that <code>:utf8</code> can.</p>

<p>There are some shortcuts for oneliners; see <a href="perlrun.html#-C-%5Bnumber%2Flist%5D">-C in perlrun</a>.</p>

<h2 id="What&#39;s-the-difference-between-UTF-8-and-utf8?"><a class="permalink" href="perlunifaq.html#What&#39;s-the-difference-between-UTF-8-and-utf8?">#</a><a id="What11"></a><a id="Whats-the-difference-between-UTF-8-and-utf8"></a>What&#39;s the difference between <code>UTF-8</code> and <code>utf8</code>?</h2>

<p><code>UTF-8</code> is the official standard. <code>utf8</code> is Perl&#39;s way of being liberal in what it accepts. If you have to communicate with things that aren&#39;t so liberal, you may want to consider using <code>UTF-8</code>. If you have to communicate with things that are too liberal, you may have to use <code>utf8</code>. The full explanation is in <a href="Encode.html#UTF-8-vs.-utf8-vs.-UTF8">&quot;UTF-8 vs. utf8 vs. UTF8&quot; in Encode</a>.</p>

<p><code>UTF-8</code> is internally known as <code>utf-8-strict</code>. The tutorial uses UTF-8 consistently, even where utf8 is actually used internally, because the distinction can be hard to make, and is mostly irrelevant.</p>

<p>For example, utf8 can be used for code points that don&#39;t exist in Unicode, like 9999999, but if you encode that to UTF-8, you get a substitution character (by default; see <a href="Encode.html#Handling-Malformed-Data">&quot;Handling Malformed Data&quot; in Encode</a> for more ways of dealing with this.)</p>

<p>Okay, if you insist: the &quot;internal format&quot; is utf8, not UTF-8. (When it&#39;s not some other encoding.)</p>

<h2 id="I-lost-track;-what-encoding-is-the-internal-format-really?"><a class="permalink" href="perlunifaq.html#I-lost-track;-what-encoding-is-the-internal-format-really?">#</a><a id="I"></a><a id="I-lost-track-what-encoding-is-the-internal-format-really"></a>I lost track; what encoding is the internal format really?</h2>

<p>It&#39;s good that you lost track, because you shouldn&#39;t depend on the internal format being any specific encoding. But since you asked: by default, the internal format is either ISO-8859-1 (latin-1), or utf8, depending on the history of the string. On EBCDIC platforms, this may be different even.</p>

<p>Perl knows how it stored the string internally, and will use that knowledge when you <code>encode</code>. In other words: don&#39;t try to find out what the internal encoding for a certain string is, but instead just encode it into the encoding that you want.</p>

<h1 id="AUTHOR"><a class="permalink" href="perlunifaq.html#AUTHOR">#</a>AUTHOR</h1>

<p>Juerd Waalboer &lt;#####@juerd.nl&gt;</p>

<h1 id="SEE-ALSO"><a class="permalink" href="perlunifaq.html#SEE-ALSO">#</a><a id="SEE"></a>SEE ALSO</h1>

<p><a href="perlunicode.html">perlunicode</a>, <a href="perluniintro.html">perluniintro</a>, <a href="Encode.html">Encode</a></p>


      </div>
      <div id="footer">
        <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p>

<p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p>


      </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
    <script src="../highlight.pack.js"></script>
    <script>hljs.highlightAll();</script>
  </body>
</html>
